<!--
  Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved.

  https://www.mall4j.com/

  未经允许，不可做商业用途！

  版权所有，侵权必究！
-->
<template>
  <!-- 工商信息 -->
  <view class="Mall4j page-store-settings-business">
    <uni-forms
      ref="businessInfoFormRef"
      :model-value="businessInfoForm"
      validate-trigger="submit"
    >
      <view class="setting-info-item">
        <uni-forms-item name="creditCode">
          <view class="title">
            <text class="star">
              *
            </text>
            <text class="txt">
              统一社会信用代码
            </text>
          </view>
          <view class="input-box">
            {{ businessInfoForm.creditCode }}
          </view>
        </uni-forms-item>
      </view>
      <view class="setting-info-item firm-name">
        <uni-forms-item name="firmName">
          <view class="title">
            <text class="star">
              *
            </text>
            <text class="txt">
              企业名称
            </text>
          </view>
          <view class="input-box">
            {{ businessInfoForm.firmName }}
          </view>
        </uni-forms-item>
      </view>
      <view class="setting-info-item">
        <uni-forms-item name="residence">
          <view class="title">
            <text class="txt">
              住所
            </text>
          </view>
          <view class="input-box">
            <text v-if="businessInfoForm.residence">
              {{ businessInfoForm.residence }}
            </text>
            <text
              v-else
              class="noyet-wrap"
            >
              暂无
            </text>
          </view>
        </uni-forms-item>
      </view>
      <view class="setting-info-item">
        <uni-forms-item name="representative">
          <view class="title">
            <text class="star">
              *
            </text>
            <text class="txt">
              法定代表人
            </text>
          </view>
          <view class="input-box">
            {{ businessInfoForm.representative }}
          </view>
        </uni-forms-item>
      </view>
      <view
        v-if="paySettlementType === 1"
        class="setting-info-item"
      >
        <uni-forms-item name="representative">
          <view class="title">
            <text class="star">
              *
            </text>
            <text class="txt">
              法人身份证
            </text>
          </view>
          <view class="input-box">
            {{ businessInfoForm.legalIds }}
          </view>
        </uni-forms-item>
      </view>
      <view
        v-if="paySettlementType === 1"
        class="setting-info-item"
      >
        <uni-forms-item name="representative">
          <view class="title">
            <text class="star">
              *
            </text>
            <text class="txt">
              法人手机号
            </text>
          </view>
          <view class="input-box">
            {{ businessInfoForm.legalPhone }}
          </view>
        </uni-forms-item>
      </view>
      <view class="setting-info-item capital">
        <uni-forms-item name="capital">
          <view class="title">
            <text class="txt">
              注册资本
            </text>
          </view>
          <view class="input-box">
            <block v-if="businessInfoForm.capital">
              {{ businessInfoForm.capital }}
              <view class="unit">
                万元
              </view>
            </block>
            <text
              v-else
              class="noyet-wrap"
            >
              暂无
            </text>
          </view>
        </uni-forms-item>
      </view>
      <view class="setting-info-item business-date">
        <uni-forms-item name="foundTime">
          <view class="title">
            <text class="txt">
              成立日期
            </text>
          </view>
          <view class="input-box">
            <text v-if="businessInfoForm.foundTime">
              {{ businessInfoForm.foundTime }}
            </text>
            <text
              v-else
              class="noyet-wrap"
            >
              暂无
            </text>
          </view>
        </uni-forms-item>
      </view>
      <view class="setting-info-item business-date">
        <uni-forms-item name="timeRange">
          <view class="title">
            <text class="txt">
              营业日期
            </text>
          </view>
          <view class="input-box">
            <span v-if="businessInfoForm.startTime && businessInfoForm.endTime">
              {{ businessInfoForm.startTime }} - {{ businessInfoForm.endTime }}
            </span>
            <span v-else-if="businessInfoForm.startTime">
              {{ businessInfoForm.startTime + ' - ' + '无固定期限' }}
            </span>
            <span
              v-else
              class="noyet-wrap"
            >
              暂无
            </span>
          </view>
        </uni-forms-item>
      </view>
      <view class="setting-info-item">
        <uni-forms-item name="businessScope">
          <view class="title">
            <text class="star">
              *
            </text>
            <text class="txt">
              经营范围
            </text>
          </view>
          <view class="textarea-box">
            <textarea
              v-model="businessInfoForm.businessScope"
              disabled
              placeholder="请输入经营范围"
              maxlength="500"
            />
          </view>
        </uni-forms-item>
      </view>
      <!-- 身份证证件照 -->
      <view class="setting-info-item">
        <view class="title">
          <text class="star">
            *
          </text>
          <text class="txt">
            法人身份证
          </text>
        </view>
        <view class="id-upload-image">
          <view class="id-front">
            <uni-forms-item name="identityCardFront">
              <view class="upload-image">
                <view
                  v-if="businessInfoForm.identityCardFront"
                  class="upload-con"
                >
                  <image
                    :src="util.checkFileUrl(businessInfoForm.identityCardFront)"
                    mode="aspectFit"
                    class="up-img-con"
                  />
                </view>
              </view>
            </uni-forms-item>
          </view>
          <uni-forms-item name="identityCardLater">
            <view class="upload-image">
              <view class="upload-con">
                <view
                  v-if="businessInfoForm.identityCardLater"
                  class="upload-con"
                >
                  <image
                    :src="util.checkFileUrl(businessInfoForm.identityCardLater)"
                    mode="aspectFit"
                    class="up-img-con"
                  />
                </view>
              </view>
            </view>
          </uni-forms-item>
        </view>
      </view>
      <!-- 营业执照电子版 -->
      <view class="setting-info-item">
        <uni-forms-item name="businessLicense">
          <view class="title">
            <text class="star">
              *
            </text>
            <text class="txt">
              营业执照电子版
            </text>
          </view>
          <view class="upload-image bus-license">
            <view class="upload-con">
              <view
                v-if="businessInfoForm.businessLicense"
                class="upload-con"
              >
                <image
                  :src="util.checkFileUrl(businessInfoForm.businessLicense)"
                  mode="heightFix"
                  class="up-img-con "
                />
              </view>
            </view>
          </view>
        </uni-forms-item>
      </view>
      <view class="setting-info-item">
        <uni-forms-item name="businessLicense">
          <view class="title">
            <text class="txt">
              审核状态
            </text>
          </view>
          <view class="input-box">
            <text>
              {{
                businessInfoForm.status === -1
                  ?
                    '未通过'
                  :
                    businessInfoForm.status === 1
                      ?
                        '已通过'
                      :
                        '未审核'
              }}
            </text>
          </view>
        </uni-forms-item>
      </view>
      <view class="setting-info-item">
        <uni-forms-item
          v-if="businessInfoForm.status === -1"
          name="businessLicense"
        >
          <view class="title">
            <text class="star">
              *
            </text>
            <text class="txt">
              拒绝原因
            </text>
          </view>
          <view class="textarea-box">
            <textarea
              v-model="businessInfoForm.remarks"
              disabled
              placeholder="暂无拒绝原因"
              maxlength="50"
            />
          </view>
        </uni-forms-item>
      </view>
      <view
        v-if="businessInfoForm.status === 0 && paySettlementType !== 1"
        class="footer"
      >
        <button
          class="button"
          type="default"
          hover-class="none"
          @tap="withdrawReview"
        >
          撤销修改申请
        </button>
      </view>
    </uni-forms>
  </view>
</template>

<script setup>
import { reactive } from 'vue'
import dayjs from 'dayjs'
import util from '@/utils/util'
const paySettlementType = uni.getStorageSync('bbcPaySettlementType')
const Data = reactive({
  // 工商信息
  businessInfoForm: {
    creditCode: '',
    firmName: '',
    residence: '',
    representative: '',
    capital: null,
    foundTime: '',
    businessScope: '',
    startTime: '',
    endTime: '',
    identityCardFront: '',
    identityCardLater: '',
    businessLicense: ''
  }
})

const { businessInfoForm } = toRefs(Data)

onShow(() => {
  getShopDetailnfo()
})

// 撤销申请
const withdrawReview = () => {
  http.request({
    url: '/shop/companyAuditing/revoke',
    method: 'put',
    data: Data.businessInfoForm.companyAuditingId.toString()
  }).then(() => {
    uni.showToast({
      title: '撤销修改申请成功',
      icon: 'none',
      duration: 1500
    })
    uni.navigateBack()
  })
}

/**
     * 获取申请信息
     */
const getShopDetailnfo = () => {
  http.request({
    url: '/shop/companyAuditing/auditInfo',
    method: 'GET'
  }).then(({ data: res }) => {
    const formData = { ...res, ...res.shopCompany }
    // 日期
    formData.foundTime = formData.foundTime ? dayjs(formData.foundTime).format('YYYY-MM-DD') : formData.foundTime
    formData.startTime = formData.startTime ? dayjs(formData.startTime).format('YYYY-MM-DD') : formData.startTime
    formData.endTime = formData.endTime ? dayjs(formData.endTime).format('YYYY-MM-DD') : formData.endTime
    Data.businessInfoForm = formData
    Data.businessInfoForm.status = res.status
  })
}
</script>

<style lang="scss" scoped>
@use "modify-infor";
</style>
